#include "StdAfx.h"
#include "myWindow.h"
#include "ExplorerForm.h"
#include "ContextForm.h"
#include "FrameListForm.h"
#include "FrameForm.h"
#include "PropertyForm.h"
System::Void myui::myWindow::button1_Click( System::Object^ sender, System::EventArgs^ e )
{
	
}

System::Void myui::myWindow::myWindow_Load( System::Object^ sender, System::EventArgs^ e )
{
	viewForms = gcnew System::Collections::Generic::Dictionary<String^, myForm^>();
	
	ShowMyForm("Frame List",true);
	ShowMyForm("Explorer",true);
	ShowMyForm("Property",true);
}

void myui::myWindow::ShowMyForm(String^ name,bool bShow)
{
	myForm^ form = nullptr;
	if(bShow)
	{
		if(name->Equals("Explorer"))
			form = gcnew	ExplorerForm();
		else if(name->Equals("Document"))
			form = gcnew	ContextForm();
		else if(name->Equals("Frame List"))
			form = gcnew	FrameListForm();
		else if(name->Equals("Frame"))
			form = gcnew    FrameForm();
		else if(name->Equals("Property"))
			form = gcnew	PropertyForm();

		if(form != nullptr)
		{
			form->Show(this->dockPanel);
			viewForms->Add(form->Text,form);
		}
	}
	else
	{
		form = viewForms[name];
		if( form != nullptr)
		{
			viewForms->Remove(name);
			form->Hide();
			form->Close();
		}
	}
}

System::Void myui::myWindow::ToolStripMenuItem_Click( System::Object^ sender, System::EventArgs^ e )
{
	ToolStripMenuItem^ item = (ToolStripMenuItem^)sender;
	item->Checked = !item->Checked;
	ShowMyForm(item->Text,item->Checked);
}

System::Void myui::myWindow::myWindow_FormClosing( System::Object^ sender, System::Windows::Forms::FormClosingEventArgs^ e )
{

}

System::Void myui::myWindow::exitToolStripMenuItem_Click( System::Object^ sender, System::EventArgs^ e )
{
	this->Close();
}

System::Void myui::myWindow::newFrameToolStripMenuItem_Click( System::Object^ sender, System::EventArgs^ e )
{
	ShowMyForm("Frame",true);
}